package com.huayi.order.service.impl;


import com.huayi.order.controller.OrderSendReq;
import com.huayi.order.entity.*;
import com.huayi.order.repository.ErpSalesOrderRepository;
import com.huayi.order.service.ErpSalesOrderService;
import com.huayi.order.thymeleaf.PagingResponse;
import com.huayi.order.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ErpSalesOrderServiceImpl implements ErpSalesOrderService {
    @Autowired
    private ErpSalesOrderRepository repository;


    @Override
    public PagingResponse<ErpSalesOrderDetailVo> getList(int pageIndex, int pageSize, String orderNum, String contactMobile, Integer saleType, Integer status, Integer startTime, Integer endTime,Integer salesManId) {
        return repository.getList(pageIndex, pageSize, orderNum, contactMobile, saleType, status, startTime, endTime,salesManId);
    }

    @Override
    public List<ErpSalesOrderItemVo> getOrderItemListAll(String orderNum, String contactMobile, Integer saleType, Integer status, Integer startTime, Integer endTime) {
        return repository.getOrderItemListAll(orderNum,contactMobile,saleType,status,startTime,endTime);
    }


    @Override
    public ErpSalesOrderDetailVo getDetailById(Long orderId) {
        return repository.getDetailById(orderId);
    }

    @Override
    public ErpSalesOrderItemEntity getOrderItemByItemId(Long orderItemId) {
        return repository.getOrderItemByItemId(orderItemId);
    }


    @Override
    public ResultVo<String> importExcelOrderForDaiFa(List<OrderImportDaiFaEntity> orderList, Integer buyerUserId) {
        return repository.importExcelOrderForDaiFa(orderList, buyerUserId);
    }

    @Override
    public void updateOrderItemSkuByItemId(ErpSalesOrderItemEntity orderItem) {
//        repository.updateOrderItemSkuByItemId(orderItem);
    }

    @Override
    public ResultVo<Integer> cancelOrder(Long orderId) {
        return repository.cancelOrder(orderId);
    }

    @Override
    public ResultVo<Integer> refundOrder(Long orderId) {
        return repository.refundOrder(orderId);
    }


    @Override
    public ResultVo<Integer> editSalesOrder(ErpSalesOrderDetailVo salesOrder) {
        return repository.editSalesOrder(salesOrder);
    }

    @Override
    public void updateLogisticsStatus(Long orderId, String logisticsCode, String logisticsCompany, String logisticsCompanyCode, String logisticsImg) {
        repository.updateLogisticsStatus(orderId,logisticsCode,logisticsCompany,logisticsCompanyCode,logisticsImg);
    }

    @Override
    public ResultVo<Integer> sendOrder(Long orderId) {
        return repository.sendOrder(orderId);
    }

    @Override
    public ResultVo<Integer> sendOrder(OrderSendReq orderSendReq) {
        return repository.sendOrder(orderSendReq);
    }

}
